#define WIN32_PLATFORM
#include <string>
#include "OS.h"
#include "common.h"

int main()
{
	std::string api = "GL";

	Render* render=getRender(api,"Window using "+api,640,480);
	
	MSG		msg;									// Windows Message Structure
	ZeroMemory(&msg,sizeof(msg));

	while(msg.message != WM_QUIT)									// Loop That Runs While done=FALSE
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?
		{
				TranslateMessage(&msg);				// Translate The Message
				DispatchMessage(&msg);				// Dispatch The Message
		}
		else										// If There Are No Messages
		{
			if (keys[VK_ESCAPE])	
			{
				PostQuitMessage(0);							// ESC or DrawGLScene Signalled A Quit
			}
			else									// Not Time To Quit, Update Screen
			{
				render->begin();
				render->setClearColor(0,0,0.5,0);
				render->clear();
				//render->draw();
				int index[] = { 0,1,2};
				float vertex[]={	-0.5f, -0.5f, 1.0f,
					-0.5f,  0.0f, 1.0f,
					0.0,  0.0, 1.0f,
					};
				render->renderIndexedVertexArray(vertex,3,index,3);
				render->swap();
				render->end();
				//getchar();
			}
		}
	}

}